package com.gitee.wsl.ext.list

import com.gitee.wsl.math.Math

/**
 * @param src1
 * Original list.
 * @param src2
 * Additional list.
 * @param <T>
 * Type of content.
 *
 * @return New list containing only the items not shared by the two lists.
</T> */
fun <T> Math.disjoint(src1: List<T>?, src2: List<T>?): List<T> {
    val results1 = if (src1 == null) mutableListOf<T>() else ArrayList(src1)
    val results2 = if (src2 == null) mutableListOf<T>() else ArrayList(src2)
    if (src2 != null) results1.removeAll(src2)
    if (src1 != null) results2.removeAll(src1)
    return combine(results1, results2)
}

fun <T> List<T>.disjoint(src2: List<T>?) = Math.disjoint(this,src2)